home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Champak 138
/
Volume 138 Aug 19 2011 - Damaged.iso
/
Games
/
wildhearts_stage_dive.swf
/
scripts
/
DefineSprite_101
/
frame_2
/
DoAction_2.as
next >
Wrap
Text File
|
2011-08-19
|
12KB
|
455 lines
function gameLoop()
{
if(rDist - (e - player._x) < 0)
{
if(!sofaContainer.sofaL)
{
sofaItems.push(sofaContainer.attachMovie("sofaL","sofaL",sofaContainer.getNextHighestDepth(),{_x:e - w,_y:123}));
}
else
{
var _loc3_ = Math.floor(rDist / sofaLength) * -1;
if(!sofaContainer["c" + _loc3_])
{
if(xv > 8.8 || xv == undefined || player.s != "slide")
{
var _loc5_ = sofaContainer.sofaL._x + sofaContainer.sofaL._width + (_loc3_ + 2) * sofaLength;
if(_loc3_ % 2 == 0)
{
sofaItems.push(sofaContainer.attachMovie("sofaCL","c" + _loc3_,sofaContainer.getNextHighestDepth(),{_x:_loc5_,_y:123}));
}
else
{
sofaItems.push(sofaContainer.attachMovie("sofaCR","c" + _loc3_,sofaContainer.getNextHighestDepth(),{_x:_loc5_,_y:123}));
}
}
else if(!sofaEnded)
{
sofaEnded = true;
sofaItems.push(sofaContainer.attachMovie("sofaR","c" + _loc3_,sofaContainer.getNextHighestDepth(),{_x:sofaContainer.sofaL._x + sofaContainer.sofaL._width + (_loc3_ + 1) * sofaLength,_y:123}));
}
}
}
}
if(!jumping)
{
speed += accel * i;
speed *= decel;
speed = speed > 0.1 ? (speed <= maxspeed ? speed : maxspeed) : 0;
rDist -= speed;
if(rDist > 0)
{
if(player._x < r)
{
if(player._x + speed >= r)
{
var _loc6_ = player._x + speed - r;
door._x -= _loc6_;
player._x = r;
}
else
{
player._x += speed;
}
}
else
{
if(door)
{
if(door._x + door._width > w)
{
door._x -= speed;
}
else
{
door.swapDepths(this.getNextHighestDepth());
door.removeMovieClip();
}
}
background._x -= speed;
}
animate(player);
_parent.gui.update(rDist / dist,speed / maxspeed);
i = 0;
}
else
{
player.gotoAndStop("ooof");
this.onEnterFrame = null;
this.gotoAndPlay("overTheLine");
}
}
else if(!endJump)
{
if(!angleMarker)
{
player.gotoAndStop("crouch");
attachMovie("angleMarker","angleMarker",this.getNextHighestDepth(),{_x:player._x,_y:player._y + player._height / 2});
angle = 0;
}
angle += angleInc;
if(angle >= 90)
{
angle = 86;
endJump = true;
}
angleMarker.mask._rotation -= angleInc;
}
else
{
if(xv == undefined)
{
angleMarker.removeMovieClip();
radians = angle * 3.141592653589793 / 180;
xv = speed * Math.cos(radians);
yv = speed * Math.sin(radians);
player.gotoAndPlay("jump");
}
background._x -= xv;
if(player._y < st)
{
player._y -= yv;
if(yv < 0)
{
if(player.s != "down")
{
player.gotoAndPlay("down");
player.s = "down";
}
}
else if(yv <= 2 && player.s != "glide")
{
player.gotoAndPlay("glide");
player.s = "glide";
}
yv -= grav;
}
else if(rDist > 0 || player.s === "missed")
{
player._y -= yv;
yv -= grav;
if(player._y >= f)
{
player._y = f;
this.onEnterFrame = null;
this.gotoAndStop("missed");
}
player.s = "missed";
}
else
{
player._y = st;
player.gotoAndStop("slide");
player.s = "slide";
if(xv >= 0)
{
xv -= frict;
}
else
{
xv = 0;
this.onEnterFrame = null;
trace("final distance: " + rDist);
this.score = rDist;
this.gotoAndPlay("jumped");
}
}
rDist -= xv;
if(rDist <= 0)
{
_parent.gui.distanceBar.distCount.text = Math.floor(rDist * -1) / 100 + "m";
_parent.gui["p" + curPlayer + "r" + curRun].text = curRun + ". " + Math.floor(rDist * -1) / 100 + "m";
}
}
if(sofaContainer.sofaL && (!jumping || endJump === true))
{
if(xv != undefined)
{
sofaContainer._x -= xv;
}
else
{
sofaContainer._x -= speed;
}
}
for(var _loc4_ in panels)
{
if(background._x + panels[_loc4_]._x + panels[_loc4_]._width < wv)
{
panels[_loc4_].removeMovieClip();
delete panels[_loc4_];
}
}
if(background._x + rightpanel < e)
{
rightpanel += panelwidth;
panels.push(spawnBg(rightpanel));
}
}
function ai()
{
if(!jumppoint)
{
jumppoint = rand(aiJSP[ailvl],aiJEP[ailvl]);
}
if(!jumpangle)
{
jumpangle = rand(aiASP[ailvl],aiAEP[ailvl]);
}
if(rDist - (e - player._x) < 0)
{
if(!sofaContainer.sofaL)
{
sofaItems.push(sofaContainer.attachMovie("sofaL","sofaL",sofaContainer.getNextHighestDepth(),{_x:e - w,_y:123}));
}
else
{
var _loc3_ = Math.floor(rDist / sofaLength) * -1;
if(!sofaContainer["c" + _loc3_])
{
if(xv > 8.8 || xv == undefined || player.s != "slide")
{
var _loc5_ = sofaContainer.sofaL._x + sofaContainer.sofaL._width + (_loc3_ + 2) * sofaLength;
if(_loc3_ % 2 == 0)
{
sofaItems.push(sofaContainer.attachMovie("sofaCL","c" + _loc3_,sofaContainer.getNextHighestDepth(),{_x:_loc5_,_y:123}));
}
else
{
sofaItems.push(sofaContainer.attachMovie("sofaCR","c" + _loc3_,sofaContainer.getNextHighestDepth(),{_x:_loc5_,_y:123}));
}
}
else if(!sofaEnded)
{
sofaEnded = true;
sofaItems.push(sofaContainer.attachMovie("sofaR","c" + _loc3_,sofaContainer.getNextHighestDepth(),{_x:sofaContainer.sofaL._x + sofaContainer.sofaL._width + (_loc3_ + 1) * sofaLength,_y:123}));
}
}
}
}
if(rDist <= jumppoint)
{
jumping = true;
}
if(!jumping)
{
i = rand(0,1);
speed += accel * i;
speed *= decel;
speed = speed > 0.1 ? (speed <= maxspeed ? speed : maxspeed) : 0;
rDist -= speed;
if(rDist > 0)
{
if(player._x < r)
{
if(player._x + speed >= r)
{
var _loc6_ = player._x + speed - r;
door._x -= _loc6_;
player._x = r;
}
else
{
player._x += speed;
}
}
else
{
if(door)
{
if(door._x + door._width > w)
{
door._x -= speed;
}
else
{
door.swapDepths(this.getNextHighestDepth());
door.removeMovieClip();
}
}
background._x -= speed;
}
animate(player);
_parent.gui.update(rDist / dist,speed / maxspeed);
i = 0;
}
else
{
player.gotoAndStop("ooof");
this.onEnterFrame = null;
this.gotoAndPlay("overTheLine");
}
}
else if(!endJump)
{
if(!angleMarker)
{
player.gotoAndStop("crouch");
attachMovie("angleMarker","angleMarker",this.getNextHighestDepth(),{_x:player._x,_y:player._y + player._height / 2});
angle = 0;
}
if(angle >= jumpangle)
{
endJump = true;
}
angle += angleInc;
if(angle >= 90)
{
angle = 86;
endJump = true;
}
angleMarker.mask._rotation -= angleInc;
}
else
{
if(xv == undefined)
{
angleMarker.removeMovieClip();
radians = angle * 3.141592653589793 / 180;
xv = speed * Math.cos(radians);
yv = speed * Math.sin(radians);
player.gotoAndPlay("jump");
}
background._x -= xv;
if(player._y < st)
{
player._y -= yv;
if(yv < 0)
{
if(player.s != "down")
{
player.gotoAndPlay("down");
player.s = "down";
}
}
else if(yv <= 2 && player.s != "glide")
{
player.gotoAndPlay("glide");
player.s = "glide";
}
yv -= grav;
}
else if(rDist > 0 || player.s == "missed")
{
player._y -= yv;
yv -= grav;
if(player._y >= f)
{
player._y = f;
this.onEnterFrame = null;
this.gotoAndStop("missed");
}
player.s = "missed";
}
else
{
player._y = st;
player.gotoAndStop("slide");
player.s = "slide";
if(xv >= 0)
{
xv -= frict;
}
else
{
xv = 0;
this.onEnterFrame = null;
this.gotoAndPlay("jumped");
}
}
rDist -= xv;
if(rDist <= 0)
{
_parent.gui.distanceBar.distCount.text = Math.floor(rDist * -1) / 100 + "m";
_parent.gui["p" + curPlayer + "r" + curRun].text = curRun + ". " + Math.floor(rDist * -1) / 100 + "m";
}
}
if(sofaContainer.sofaL && (!jumping || endJump === true))
{
if(xv != undefined)
{
sofaContainer._x -= xv;
}
else
{
sofaContainer._x -= speed;
}
}
for(var _loc4_ in panels)
{
if(background._x + panels[_loc4_]._x + panels[_loc4_]._width < w)
{
panels[_loc4_].removeMovieClip();
delete panels[_loc4_];
}
}
if(background._x + rightpanel < e)
{
rightpanel += panelwidth;
panels.push(spawnBg(rightpanel));
}
}
function spawnBg(x)
{
if(spawnIndex == undefined)
{
spawnIndex = -1;
}
var _loc1_ = ["painting","clock","plant","shelves","lamp","painting"];
trace("spawnBg:" + spawnIndex + " " + _loc1_.length);
if(spawnIndex < _loc1_.length)
{
spawnIndex++;
return background.attachMovie(_loc1_[spawnIndex],"bg" + Math.floor(x),background.getNextHighestDepth(),{_x:x,cacheAsBitmap:true});
}
}
function rand(min, max)
{
return Math.floor(Math.random() * (max - min + 1)) + min;
}
function animate(t)
{
if(this.speed > 0)
{
this.aCount = this.aCount + 1;
this.aSpeed = Math.floor((this.afps - this.speed / this.maxspeed * this.afps) * 0.25);
if(this.aSpeed <= this.aCount)
{
this.aCount = 0;
t.play();
}
}
else
{
t.gotoAndPlay("stand");
}
}
function pauseGame()
{
if(isPaused)
{
isPaused = false;
this.onEnterFrame = gameLoop;
}
else
{
isPaused = true;
this.onEnterFrame = null;
}
}
function slideSofa()
{
speed *= 0.97;
if(speed > 1)
{
sofaContainer._x -= speed;
player._x -= speed;
background._x -= speed;
}
else
{
this.onEnterFrame = null;
play();
}
}